package com.zyb.warehouse.mapper;

import com.zyb.warehouse.dto.Page;
import com.zyb.warehouse.entity.InStore;
import com.zyb.warehouse.entity.Purchase;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * Description:采购表持久层接口
 */
@Mapper
public interface PurchaseMapper {

    /**
     * 添加采购单
     *
     * @param purchase
     * @return
     */
    Integer insertPurchase(Purchase purchase);

    /**
     * 查询采购列表的总记录数
     *
     * @param purchase
     * @return
     */
    Integer selectPurchaseTotal(Purchase purchase);

    /**
     * 分页查询采购单
     *
     * @param page
     * @param purchase
     * @return
     */
    List<Purchase> pagePurchase(@Param("page") Page page, @Param("purchase") Purchase purchase);

    /**
     * 删除采购单
     *
     * @param buyId
     * @return
     */
    @Delete("delete from buy_list where buy_id=#{buyId}")
    Integer deletePurchase(Integer buyId);

    /**
     * 修改采购单
     *
     * @param purchase
     * @return
     */
    Integer updatePurchase(Purchase purchase);

    /**
     * 把采购单状态改为已入库
     *
     * @param buyId
     * @return
     */
    @Update("update buy_list set is_in=1 where buy_id=#{buyId}")
    Integer updatePurchaseState(Integer buyId);
}
